package com.atguigu.jxc.controller;

import com.atguigu.jxc.domain.ServiceVO;
import com.atguigu.jxc.entity.DamageList;
import com.atguigu.jxc.entity.DamageListGoods;
import com.atguigu.jxc.entity.OverflowList;
import com.atguigu.jxc.entity.OverflowListGoods;
import com.atguigu.jxc.service.DamageListGoodsService;
import com.atguigu.jxc.service.OverflowListGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ClassName: OverflowListGoodsController
 * Description:
 * Date: 2022/1/16 23:20
 *
 * @version:
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/overflowListGoods")
public class OverflowListGoodsController {

    @Autowired
    private OverflowListGoodsService overflowListGoodsService;



    @PostMapping("/save")
    public ServiceVO saveOverflowListGoods(OverflowList overflowList, String overflowListGoodsStr,HttpSession session){





        try {
            overflowListGoodsService.saveOverflowListGoods(overflowList,overflowListGoodsStr,session);
            return new ServiceVO<>(100,"请求成功");

        }catch (Exception e){
            e.printStackTrace();
        }

        return new ServiceVO<>(101,"添加失败");


    }


    @PostMapping("/list")
    public Map<String,Object> getOverflowListGoods(String  sTime, String  eTime){
        List<OverflowList> overflowListList = overflowListGoodsService.getOverflowListGoods(sTime,eTime);


        HashMap<String, Object> stringObjectHashMap = new HashMap<>();

        stringObjectHashMap.put("rows",overflowListList);
        return stringObjectHashMap;
    }


    @PostMapping("/goodsList")
    public Map<String,Object> getGoodsList(Integer overflowListId){
        List<OverflowListGoods> overflowListGoodsList = overflowListGoodsService.getGoodsList(overflowListId);


        HashMap<String, Object> stringObjectHashMap = new HashMap<>();

        stringObjectHashMap.put("rows",overflowListGoodsList);
        return stringObjectHashMap;
    }

}
